package cn.edu.scau.cmi.huangxiyan.multipleton;

import java.util.HashMap;
import java.util.Map;

public class Marshal {
	private static final int MAX = 10;
	private static Map<String, Marshal> marshalMap = new HashMap<String, Marshal>();
	private String name = null;

	private Marshal(String name) {
		this.setName(name);
	}

	public static Map<String, Marshal> addInstance(String name) {
		if (marshalMap.size() < MAX && !(name == null) && !marshalMap.containsKey(name)) {
			Marshal marshal = new Marshal(name);
			marshalMap.put(name, marshal);
		}

		return marshalMap;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
